Sub 행배경색채우기()
'
' 행배경색채우기 매크로
'
' 바로 가기 키: Ctrl+r
'
    '변수 선언
    Dim rowno1 As Long, rowno2 As Long
    Dim con As String
    
    '사용자 입력 받기
    rowno1 = Val(InputBox("배경색을 지정할 행의 배수 값을 숫자로 입력해주세요", "숫자 입력창", 2))
    If rowno1 <= 0 Then Exit Sub
    rowno2 = rowno1 * 2
    
    '조건부 서식의 조건
    con = "=AND(MOD(ROW(A1)," & rowno2 & ")>=1,MOD(ROW(A1)," & rowno2 & ")<=" & rowno1 & ")"
    
    '기존 조건부 서식 삭제
    행배경색지우기
    
    '범위 지정
    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    
    '조건부 서식
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:=con
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent5
        .TintAndShade = 0.799981688894314
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Range("A1").Select
End Sub



Sub 행배경색지우기()
'
' 행배경색지우기 매크로
'

'
    Range("A3").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.FormatConditions.Delete
    Range("A1").Select
End Sub
